<html>
<head>
    <style type="text/css">
        <!--
        body, td, div, span, p {
            font-family: arial, sans-serif;
        }

        a {
            color: #0000cc;
        }

        a:visited {
            color: #551a8b;
        }

        a:active {
            color: #ff0000;
        }

        body {
            margin: 0px;
            padding: 0px;
            background-color: white;
        }

        -->
    </style>
</head>
<body>
<script src="/ig/f/xZbgsit8tFM/ig.js"></script>
<script src="/ig/f/8JdLW-FnPCU/lib/liburchin.js"></script>
<script src="/ig/f/byCr3ZiY_GI/lib/libanalytics.js"></script>
<script>function sendRequest(iframe_id, service_name, args_list, remote_relay_url, callback, local_relay_url) {
    _IFPC.call(iframe_id, service_name, args_list, remote_relay_url, callback, local_relay_url);
}
function _IFPC_SetPref(keyValues) {
    keyValues.unshift("remote_iframe_0");
    sendRequest("remote_iframe_0", "set_pref", keyValues, "http://www.google.com/ig/ifpc_relay", null, "");
}
function _IG_SetTitle(title) {
    throw new Error("To use this feature, you must add " + "<Require feature='settitle'/> to your <ModulePref> tag.");
}
var ifpc_height = 0;
var last_opt_height;
function _IFPC_AdjustIFrameHeight(opt_height) {
    last_opt_height = opt_height;
    var new_height = ifpc_height;
    var el = document.getElementById("remote_0");
    if (opt_height !== undefined) {
        opt_height = parseInt(opt_height, 10);
        opt_height = isNaN(opt_height) ? -1 : opt_height;
    } else {
        opt_height = -1;
    }
    if (opt_height >= 0) {
        new_height = opt_height;
    } else if (el) {
        var sh = el.scrollHeight;
        var oh = el.offsetHeight;
        new_height = sh > oh ? sh : oh;
    }
    if (ifpc_height != new_height) {
        sendRequest("remote_iframe_0", "resize_iframe", ["remote_iframe_0", new_height], "http://www.google.com/ig/ifpc_relay", null, "");
        ifpc_height = new_height;
    }
}
function _IG_AdjustIFrameHeight(opt_height) {
    if (_args()["synd"] == "open") {
        return;
    }
    setTimeout(function() {
        _IFPC_AdjustIFrameHeight(opt_height);
    }, 10);
}
_IG_AddEventHandler("resize", function() {
    _IG_AdjustIFrameHeight(last_opt_height);
});</script>
<script><!--
_et = "ZwL9qRo9";
_IG_Prefs._parseURL("0");
_IG_Prefs._add("0", "", "");
// -->
</script>
<script><!--
_IG_Prefs._add("0", "up_title", "My Earnings");
_IG_Prefs._add("0", "up_breakName", "bathroom break");
_IG_Prefs._add("0", "up_currencySymbol", "$");
_IG_Prefs._add("0", "up_salary", "20000");
_IG_Prefs._add("0", "up_startTime", "09:00");
_IG_Prefs._add("0", "up_endTime", "17:00");
_IG_Prefs._add("0", "up_lunchTime", "1:00");
_IG_Prefs._add("0", "up_taxRate", "");
_IG_Prefs._add("0", "up_clockTickInterval", "1");
_IG_Prefs._add("0", "up_timerTickInterval", "2");
_IG_Prefs._add("0", "up_showClock", "1");
_IG_Prefs._add("0", "up_is24h", "1");
_IG_Prefs._add("0", "up_showRule", "1");
_IG_Prefs._add("0", "up_confirmReset", "1");
_IG_Prefs._add("0", "up_timerPaused", "false");
_IG_Prefs._add("0", "up_timerStart", "1182114654187");
_IG_Prefs._add("0", "up_salaryH", "");
_IG_Prefs._add("0", "up_showTimer", "1");
_IG_Prefs._add("0", "up_showToday", "1");
_IG_Prefs._add("0", "up_.lang", "en");
_IG_Prefs._add("0", "up_.country", "us");
_IG_Prefs._add("0", "up_synd", "ig");
// -->
</script>
<!-- Copyright 2007 and beyond, Google Inc.  To use gadgets on your own site, visit http://www.google.com/webmasters/gadgets.  To create your own gadgets, visit http://www.google.com/apis/gadgets -->
<div id=remote_0 style="border:0;padding:0;margin:0;width:100%;;overflow:hidden;">
<div class="modtitle" style="background: white; border: 0px; ">
    <div id="clockHolder0" style="text-align:center; display:none; ">

        <span id="clock0" style="font-weight:bold;font-size:200%;">&nbsp;</span>
        <br/>

        <span id="toggleTimer0" style="font-size:75%; position:relative; left:0px; text-align:left; cursor:pointer;">Hide earnings</span>
    </div>

    <div id="timerHolder0" style="text-align:center; font-size:90%;">
        <hr id="hrule0" style="height:1px; border-top:0px; display:none;"/>

        <span id="timer0" style="font-weight:bold;"></span>

        <div id="earningsHolder0" style="text-align:center;">
            <h3>
                <span id="earnings0"></span><br/>
                <span id="today0"></span>

            </h3>
            <button id="startStop0" style="width:65px;">Start</button>
            &nbsp;
            <button id="reset0" style="width:65px;">Reset</button>
        </div>
    </div>

</div>
<script>

function MyEarnings0()
{
    this.prefs = new _IG_Prefs(0);
    this.timerPaused = false;
    this.timerStart = new Date();

    this.timerTickIntervals = [60000, 1000, 60];

    this.showClock = this.prefs.getBool("showClock");
    this.is24h = this.prefs.getBool("is24h");

    this.clockTickInterval = 1000;
    this.timerTickInterval = 60;

    this.startTime = this.prefs.getString("startTime");
    this.endTime = this.prefs.getString("endTime");
    this.lunchTime = this.prefs.getString("lunchTime");
    this.breakName = this.prefs.getString("breakName");
    this.confirmReset = this.prefs.getString("confirmReset");
    this.currencySymbol = this.prefs.getString("currencySymbol").substring(0, 1);

    this.showTimer = this.prefs.getString("showTimer");
    this.showToday = this.prefs.getString("showToday");

    this.startText = "Start";
    this.pauseText = "Pause";
    this.resumeText = "Resume";

    this.taxRate = this.prefs.getString("taxRate");
    this.salary = this.prefs.getInt("salary");

    this.dayMillis = 0;
    this.dailyRate = 0;
    this.workTicks = 0;

    this.initdayMillis();

    this.timerDiv = _gel("timer0");
    this.earningsDiv = _gel("earnings0");
    this.clockDiv = _gel("clock0");
    this.startStopDiv = _gel("startStop0");
    this.resetDiv = _gel("reset0");
    this.todayDiv = _gel("today0");
}

MyEarnings0.prototype.createMethodReference = function(object, methodName)
{
    return function () {
        object[methodName].apply(object, arguments);
    };
}

MyEarnings0.prototype.main = function()
{
    _gel("startStop0").onclick = this.createMethodReference(this, "startTimer");
    _gel("reset0").onclick = this.createMethodReference(this, "resetTimer");
    _gel("toggleTimer0").onclick = this.createMethodReference(this, "toggleTimer");

    _gel("hrule0").style.display = this.prefs.getString("showRule") == 1 ? "" : "none";
    _gel("timerHolder0").style.display = this.showTimer == 1 ? "" : "none";
    _gel("toggleTimer0").innerHTML = (this.showTimer == 1 ? "Hide" : "Show") + " earnings";

    if (this.showClock)
    {
        _gel("clockHolder0").style.display = "";
        this.tickClock();
    }
    this.tickTimer();
    _IG_Analytics("UA-582167-14", "/");
}

MyEarnings0.prototype.readTime = function(aTime, isDuration)
{
    var aDate = new Date();
    if (isDuration) {
        aDate.setTime(0);
    }
    var hM = aTime.split(":");
    aDate.setHours(hM[0]);
    aDate.setMinutes(hM[1])
    return aDate;
}

MyEarnings0.prototype.initdayMillis = function()
{
    this.startTime = this.readTime(this.startTime);
    this.endTime = this.readTime(this.endTime);
    this.lunchTime = this.readTime(this.lunchTime, true);

    this.dailyRate = this.tax(this.salary) / (12 * ((5 / 7) * 365) / 12);
    this.workTicks = this.endTime.getTime() - (this.startTime.getTime() + this.lunchTime.getTime());
}


MyEarnings0.prototype.tickTimer = function()
{
    var now = new Date();
    var duration = 0;
    this.todayDiv.innerHTML = this.getDailyEarnings(now);

    //if timer stopped or paused
    if ((this.timerStart == "") || (this.timerPaused))
    {
        duration = this.getTimeSince(now.getTime() - this.timerStart);
        this.startStopDiv.innerHTML = this.timerPaused ? this.resumeText : this.startText;
        this.timerDiv.innerHTML = this.formatTime(duration, false);
        this.earningsDiv.innerHTML = this.getTimerEarnings(duration);
    }
    else
    {
        this.startStopDiv.innerHTML = this.pauseText;
        duration = this.getTimeSince(this.timerStart);
    }

    this.earningsDiv.innerHTML = this.getTimerEarnings(duration);
    this.timerDiv.innerHTML = this.formatTime(duration, false);

    setTimeout("gadget0.tickTimer()", this.timerTickInterval);
}

MyEarnings0.prototype.tickClock = function()
{
    var now = new Date();
    this.clockDiv.innerHTML = this.formatTime(now, true);
    setTimeout("gadget0.tickClock()", this.clockTickInterval);
}


MyEarnings0.prototype.formatTime = function (aDate, isClock)
{
    var hrs = aDate.getHours();
    var min = aDate.getMinutes();

    var sec = "";
    var showSec = (isClock && (this.clockTickInterval <= this.timerTickIntervals[1])) || (!isClock && (this.timerTickInterval <= this.timerTickIntervals[1])) ? true : false;
    if (showSec)
    {
        sec = aDate.getSeconds();
        if (sec < 10) {
            sec = "0" + sec;
        }
        if (isClock) {
            sec = ":" + sec + " ";
        } else {
            sec += "s ";
        }
    }

    var mil = "";
    var showMils = (isClock && (this.clockTickInterval == this.timerTickIntervals[2])) || (!isClock && (this.timerTickInterval == this.timerTickIntervals[2])) ? true : false;
    if (showMils)
    {
        mil = aDate.getMilliseconds();
        mil = "" + mil;
        mil = mil.substring(0, 2);
        if (mil < 10) {
            mil = "0" + mil;
        }
    }

    var don = "";
    if (!this.is24h)
    {
        if (isClock)
        {
            don = " AM";
            if (hrs >= 12) {
                don = " PM";
            }
            if (hrs > 12) {
                hrs -= 12;
            }
            if (hrs == 0) {
                hrs = 12;
            }
        }
    }
    else
    {
        if (hrs < 10) {
            hrs = "0" + hrs;
        }
    }

    if (min < 10) {
        min = "0" + min;
    }

    if (isClock)
    //format clock
    {
        return hrs + ":" + min + sec + mil + " " + don;
    }
    else
    //format timer
    {
        return hrs + "h " + min + "m " + sec + mil + " " + don;
    }
}

MyEarnings0.prototype.resetTimer = function()
{
    this.resetDiv.blur();
    if (this.confirmReset)
    {
        if (!confirm("Are you sure you want to reset this timer?"))
        {
            return;
        }
    }
    this.timerStart = "";
    //this.prefs.set("timerStart", this.timerStart);

    var duration = this.getTimeSince(new Date().getTime() - this.timerStart);
    this.startStopDiv.innerHTML = this.timerPaused ? this.resumeText : this.startText;
    this.timerDiv.innerHTML = this.formatTime(duration, false);
    this.earningsDiv.innerHTML = this.getTimerEarnings(duration);


    this.timerPaused = false;
    //this.prefs.set("timerPaused", this.timerPaused ? "1" : "0");

}

MyEarnings0.prototype.getTimeSince = function(timerStart)
{
    var ticks;

    if (timerStart == "")
    {
        ticks = 0;
    }
    else
    {
        ticks = new Date().getTime() - timerStart;
    }

    return new Date(ticks);
}

MyEarnings0.prototype.startTimer = function()
{
    var startTime;

    if ((this.timerPaused) || (this.timerStart == ""))
    //start / resume
    {
        if (this.timerPaused)
        {
            this.timerStart = new Date().getTime() - this.timerStart;
        }

        this.timerPaused = false;
        if (this.timerStart == "")
        {
            this.timerStart = new Date().getTime();
        }
    }
    else
    //stop / pause
    {
        this.timerPaused = true;
        //put timer time into timerStarted
        this.timerStart = this.getTimeSince(this.timerStart).getTime();
    }

    //this.prefs.set("timerPaused", this.timerPaused ? "1" : "0");
    //this.prefs.set("timerStart", this.timerStart);
    this.tickTimer();
    this.startStopDiv.innerHTML = (!this.timerPaused) ? this.pauseText : this.resumeText;
}

MyEarnings0.prototype.getEarnings = function(duration)
{
    return ((duration.getTime() * this.dailyRate) / this.workTicks).toFixed(2);
}

MyEarnings0.prototype.getTimerEarnings = function(duration)
{
    return  "Your " + this.breakName + " has earned you " + this.currencySymbol + this.getEarnings(duration);
}

MyEarnings0.prototype.getDailyEarnings = function(now)
{
    duration = this.getTimeSince(this.startTime);
    if (now.getTime() > this.endTime.getTime())
    {
        return "Today you earned " + this.currencySymbol + this.dailyRate.toFixed(2);
    }
    else if (now.getTime() < this.startTime.getTime())
    {
        return "You have yet to earn anything today!";
    }
    else
    {
        return "So far today, you have earned " + this.currencySymbol + this.getEarnings(duration);
    }
}

MyEarnings0.prototype.tax = function(amount)
{

    //flat user specified tax rate
    if (this.taxRate != "")
    {
        return amount * (1 - this.taxRate);
    }

    //Under 65 yr old personal allowance
    //var pa1=4745;	2004-05
    //var pa1=4895;	2005-06
    //var pa1=5035;	2006-07
    var pa1 = 5225;
    //	2007-08

    //Income Tax Rates
    var tax1 = 0.1;
    var tax3 = 0.22;
    var tax4 = 0.4;

    //Income Tax Bands
    //var band1=2020;	2004-05
    //var band1=2090;	2005-06
    //var band1=2150;	2006-07
    var band1 = 2230;
    //  2007-08

    //var band2=31400;	2004-05
    //var band2=32400;	2005-06
    //var band2=33300;	2006-07
    var band2 = 34600;
    //  2007-08

    var taxable = 0;
    var tax = -1000;
    var net = 0;

    var ni = 0;
    var niadd = 0.01;
    //extra ni for earnings > uel

    //LEL for NI
    //var nilower=4745; 	2004-05
    //var nilower=4895;	2005-06
    //var nilower=5035;	2006-07
    var nilower = 5225;
    // 2007-08

    //UEL for NI
    //var niupper=31720;	2004-05
    //var niupper=32760;	2005-06
    //var niupper=33540;	2006-07
    var niupper = 34840;
    // 2007-08

    var ci = 0.11;
    var co = 0.094;
    var extni = 0;

    earnings = amount


    //  <!** START SINGLE PERSON UNDER 65 **!>

    if (earnings < pa1) {
        tax = 0;
        net = earnings;
    } else if (earnings <= (pa1 + band1)) {
        var taxable = earnings - pa1;
        tax = Math.round(taxable * tax1);
        net = earnings - tax;
    } else if (earnings <= (pa1 + band2)) {
        var taxable = earnings - (pa1 + band1);
        tax = Math.round((taxable * tax3) + (band1 * tax1));
        net = earnings - tax;
    } else {
        var taxable = earnings - (pa1 + band2);
        tax = Math.round((taxable * tax4) + ((band1 * tax1) + ((band2 - band1) * tax3)));
        net = earnings - tax;
    }

    // <!** TIDY RESULTS - SOMETIMES THE RESULTS GET MUNGED **!>
    net = parseFloat(net);
    tax = parseFloat(tax);

    // <!** DETECT NEGATIVE TAX VALUES **!>
    if (tax <= 0) {
        net = earnings;
        tax = 0;
    }

    // <!** IN OR OUT OF SERPS? **!>
    var inserps = true;
    var nirate = (inserps) ? ci : co ;

    // <!** CALCULATE NATIONAL INSURANCE CONTRIBUTIONS **!>
    // <!** START CONTRACTED IN EMPLOYEE **!>
    if (earnings < nilower) {
        ni = 0;
    } else {
        if (earnings > niupper) {
            ni = (niupper - nilower) * nirate;
            extni = (earnings - niupper) * niadd;
            ni += extni;
        } else {
            ni = nirate * (earnings - nilower);
        }
    }
    // <!** END CONTRACTED IN EMPLOYEE **!>

    // <!** REFORMAT DATA AND DEDUCT NI CONTRIBUTIONS IF ANY **!>
    if (ni > 0) {
        net -= ni;
    }


    return value = Math.round(net);
}


MyEarnings0.prototype.toggleTimer = function()
{

    this.showTimer = this.showTimer == 0 ? 1 : 0;
    //this.prefs.set("showTimer", this.showTimer);

    _gel("toggleTimer0").innerHTML = (this.showTimer == 1 ? "Hide" : "Show") + " earnings";
    _gel("timerHolder0").style.display = this.showTimer == 1 ? "" : "none";

}

_IG_RegisterOnloadHandler(function()
{
    gadget0 = new MyEarnings0;
    gadget0.main();
});
</script>

<style>
    .modtitle {
        color: #333333;
    }
</style>

</div>
<script><!--
_IG_TriggerEvent("domload");
// -->
</script>
</body>
</html>